package com.stone.framework.user.entity;

import javax.persistence.Column;
import javax.persistence.Entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.stone.framework.core.entity.CommonEntity;

/*
 * 使用主键关联而非业务唯一标识关联，防止业务唯一标识变更导致关联表数据不一致
 */
@TableName("ST_ROLE_USER")
@Entity(name = "ST_ROLE_USER")
public class RoleUser extends CommonEntity {

    private static final long serialVersionUID = 1893527398539994088L;

    @TableField("USER_ID")
    @Column(name = "USER_ID")
    private Long userId;

    @TableField("ROLE_ID")
    @Column(name = "ROLE_ID")
    private Long roleId;

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((roleId == null) ? 0 : roleId.hashCode());
        result = prime * result + ((userId == null) ? 0 : userId.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        RoleUser other = (RoleUser)obj;
        if (roleId == null) {
            if (other.roleId != null)
                return false;
        } else if (!roleId.equals(other.roleId))
            return false;
        if (userId == null) {
            if (other.userId != null)
                return false;
        } else if (!userId.equals(other.userId))
            return false;
        return true;
    }
}
